<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
    <head>
        <th:block th:include="include :: header('排班计划列表')"/>
        <style>
            /*.bootstrap-table tr th .th-inner{*/
            /*    border: 1px solid #F00;*/
            /*}*/

            /*.bootstrap-table tr.no-records-found td {*/

            /*    border: 1px solid #F00;*/
            /*}*/
            /*.table-bordered th, .table-bordered td { border: 1px solid #ddd!important }*/
            .table-height {
                min-height: 75%;
            }

            table.table-bordered {
                border: 1px solid black !important;
                margin-top: 20px;
            }

            table.table-bordered > thead > tr > th {
                border: 1px solid black !important;
            }

            table.table-bordered > tbody > tr > td {
                border: 1px solid black !important;
            }

        </style>
    </head>
    <body class="gray-bg">
        <div class="container-div">
            <div class="row">
                <div class="col-sm-12 search-collapse">
                    <form id="formId">
                        <div class="select-list">
                            <ul>
                                <li>
                                    <label>班组：</label>
                                    <!--                                    <select name="tid" th:with="list=${@team.selectHisTeamGroupList('E')}">-->
                                    <!--                                        <option th:each="t : ${list}" th:text="${t.teamName}" th:value="${t.id}"></option>-->
                                    <!--                                    </select>-->
                                    <input type="text" th:value="${teamGroup.teamName}" disabled/>

                                </li>
                                <!--                                <li>-->
                                <!--                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i-->
                                <!--                                            class="fa fa-search"></i>&nbsp;搜索</a>-->
                                <!--                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i-->
                                <!--                                            class="fa fa-refresh"></i>&nbsp;重置</a>-->
                                <!--                                </li>-->
                            </ul>
                        </div>
                    </form>
                </div>
                <div class="col-sm-12 select-table table-height">
                    <div class="bootstrap-table bootstrap3">
                        <!--                        <div class="fixed-table-toolbar">-->
                        <!--                            <div class="bs-bars pull-left">-->
                        <!--                                <div class="btn-group-sm" id="toolbar" role="group">-->
                        <!--                                    <a class="btn btn-success" onclick="$.operate.addTab()">-->
                        <!--                                        <i class="fa fa-plus"></i> 添加-->
                        <!--                                    </a>-->
                        <!--                                    <a class="btn btn-primary single disabled" onclick="$.operate.edit()">-->
                        <!--                                        <i class="fa fa-edit"></i> 修改-->
                        <!--                                    </a>-->
                        <!--                                    <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">-->
                        <!--                                        <i class="fa fa-remove"></i> 删除-->
                        <!--                                    </a>-->
                        <!--                                    <a class="btn btn-warning" onclick="$.table.exportExcel()">-->
                        <!--                                        <i class="fa fa-download"></i> 导出-->
                        <!--                                    </a>-->
                        <!--                                </div>-->
                        <!--                            </div>-->
                        <!--                        </div>-->

                        <div class="fixed-table-container" style="padding-bottom: 0px;">
                            <div class="fixed-table-body" th:with="tid=${teamGroup.id}">
                                <form id="form-inf-add" action="/plan/add" method="post">
                                    <input type="hidden" name="tid" th:value="${teamGroup.id}"/>
                                    <table id="bootstrap-table" class="table table-bordered table-hover"
                                           th:with="bc=${shifts.size}">
                                        <thead class="">
                                        <tr>
                                            <th style="text-align: center;">
                                                <div class="th-inner ">职员</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                            <th style="text-align: center;" th:colspan="${bc}">
                                                <div class="th-inner ">星期一</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                            <th style="text-align: center;" th:colspan="${bc}">
                                                <div class="th-inner ">星期二</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                            <th style="text-align: center;" th:colspan="${bc}">
                                                <div class="th-inner ">星期三</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                            <th style="text-align: center;" th:colspan="${bc}">
                                                <div class="th-inner ">星期四</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                            <th style="text-align: center;" th:colspan="${bc}">
                                                <div class="th-inner ">星期五</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                            <th style="text-align: center; " th:colspan="${bc}">
                                                <div class="th-inner ">星期六</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                            <th style="text-align: center; " th:colspan="${bc}">
                                                <div class="th-inner ">星期日</div>
                                                <div class="fht-cell"></div>
                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody th:with="tds=${7 * bc -1}">
                                        <tr class="no-records-found">
                                            <td></td>
                                            <td th:each="n:${#numbers.sequence(0, tds)}">[[${shifts[n%bc].shift}]]</td>
                                        </tr>
                                        <tr class="no-records-found" th:each="user:${users}">
                                            <td>[[${user.userName}]]</td>
                                            <td th:each="n:${#numbers.sequence(0,tds)}"
                                                th:with="sid=${shifts[n%bc].id},day=${n/bc+1}">
                                                <input type="checkbox" name="works"
                                                       th:value="|${tid},${sid},${user.userId},${day},Y|"
                                                       onclick="selected(this)"/>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </form>
                            </div>
                            <div class="fixed-table-footer">
                                <div class="fixed-table-toolbar">
                                    <div class="bs-bars pull-left">
                                        <div class="btn-group-sm" id="toolbar" role="group">
                                            <button id="submit-btn" class="btn btn-success" onclick="submitHandler()">
                                                <i class="fa fa-plus"></i> 提交
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
        <th:block th:include="include :: footer"/>
        <script th:inline="javascript">
            var prefix = ctx + "his/plan";

            function selected(obj) {
                if (obj.checked) {
                    obj.parentNode.style.background = "#00CCFF";
                } else {
                    obj.parentNode.style.background = "none";
                }
            }

            function submitHandler() {
                $.operate.saveModal(prefix + "/add", $('#form-inf-add').serialize(), callback);
                this.close();
            }

            function callback(result) {
                if (result.code == web_status.SUCCESS) {
                    $.modal.alertSuccess(result.msg);
                    $("#submit-btn").attr("disabled",true);
                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg);
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            }
        </script>
    </body>
</html>